package chapter4;

import org.eclipse.jface.window.ApplicationWindow;
import org.eclipse.swt.*;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.MouseListener;
import org.eclipse.swt.widgets.*;

public class ButtonEvent1 extends ApplicationWindow{

	public ButtonEvent1() {
		super(null);
	}
	
	@Override
	protected Control createContents(Composite parent) {
		Button button = new Button(parent, SWT.PUSH | SWT.CENTER);
		
		MouseListener example = new MouseListener(){

			@Override
			public void mouseDoubleClick(MouseEvent e) {
				System.out.println("double click ");
				
			}

			@Override
			public void mouseDown(MouseEvent e) {
				System.out.println("mouse presionado");
			}

			@Override
			public void mouseUp(MouseEvent e) {
				System.out.println("mouse soltado");
			}
			
		};
		
		button.addMouseListener(example);
		
		button.setText("luik");
		
		return super.createContents(parent);
	}

	public static void main(String[] args) {
		ButtonEvent1 be1 = new ButtonEvent1();
		be1.setBlockOnOpen(true);
		be1.open();
		
		Display.getCurrent().dispose();
	}
}
